#!/bin/bash

mkdir -p /git-cache/ci-plugins/git-clone-yyds/master

cd /git-cache/ci-plugins/git-clone-yyds/
umount test/workspace
rm -rf test/

docker pull cnbcool/git-clone-yyds:dev

docker run --rm \
    -e TZ=Asia/Shanghai \
    --privileged \
    \
    -v /git-cache/ci-plugins/git-clone-yyds/master:/git-cache/ci-plugins/git-clone-yyds/master \
    -v $(pwd):/yyds:rshared \
    -e PLUGIN_GIT_DOAMIN="cnb.cool" \
    -e PLUGIN_GIT_CACHE="/git-cache/ci-plugins/git-clone-yyds/master" \
    -e PLUGIN_WORKSPACE_ID="test" \
    -e PLUGIN_WORKSPACE_NAME="workspace" \
    \
    -e PLUGIN_BUILD_USER=${CNB_BUILD_USER} \
    -e PLUGIN_GIT_USERNAME="private" \
    -e PLUGIN_GIT_PASSWORD=${TGIT_TOKEN} \
    -e PLUGIN_NO_CHECK_AUTH=true \
    \
    -e PLUGIN_SOURCE_URL="https://cnb.cool/cnb/cool/git-clone-yyds.git" \
    -e PLUGIN_SOURCE_REF="refs/heads/staging"  \
    -e PLUGIN_SOURCE_SHA="12a768b142fb150053894b31af5a89c0738135b1" \
    \
    -e PLUGIN_TARGET_URL="https://cnb.cool/cnb/cool/git-clone-yyds.git" \
    -e PLUGIN_TARGET_REF="refs/heads/master" \
    -e PLUGIN_TARGET_SHA=""f24f080a49223ee5a4dfdac96c42fc91bd512131 \
    \
    -e PLUGIN_NEED_MERGE=true \
    -e PLUGIN_NEED_SUBMODULE="true" \
    -e PLUGIN_NEED_LFS="true" \
    \
    cnbcool/git-clone-yyds:dev
